import React, { PureComponent, createRef } from 'react'

class HelloWord extends PureComponent {

  test() {
    console.log('ref test -------');
  }
  render() {
    return (
      <div>hello word</div>
    )
  }
}



export class App extends PureComponent {
  constructor() {
    super()
    this.hwRef = createRef()
  }
  getNativeDOM() {
    console.log(this.hwRef.current);
    this.hwRef.current.test()
  }
  render() {
    return (
      <div>
        <p>App - ref</p>
        <HelloWord ref={this.hwRef} />
        <button onClick={() => this.getNativeDOM()}>获取DOM</button>
      </div>
    )
  }
}

export default App